<template>
  <div class="chart">
    <div class="center-node">
      <div :class="`bg ${$get(centerNode,'value')}`"></div>
      <div class="title">
        {{$get(centerNode,'name')}}
      </div>
      <div class="desc"> {{$get(centerNode,'desc')}}</div>
    </div>
    <div class="arrow">
      <div class="item" v-for="item in otherNode" :key="item.name">
        <div class="val">100Mbps</div>
      </div>
    </div>
    <div class="node-list">
      <div class="node" v-for="item in otherNode" :key="item.name">
        <div class="bg " :class="`bg ${item.value}`"></div>
        <div class="title">{{item.name}}</div>
        <div class="desc">{{item.desc}}</div>
      </div>
    </div>
  </div>
</template>

<script>
  import { provideList } from './config'
  import _ from 'lodash'
  export default {
    props: {
      nodeInfo: {
        type: Object,
        default: () => {
          return {
            centerNode: 'cs',
            nodeList: []
          }
        }
      }
    },
    data () {
      return {
        provideList
      }
    },
    computed: {
      centerNode () {
        let { centerNode } = this.nodeInfo
        let node = this.provideList.find(e => e.value === centerNode)
        return node
      },
      // provide () {
      //   let { centerNode, nodeList } = this.nodeInfo
      //   console.log('nodeList', nodeList)
      //   let item = nodeList.filter(e => e.provide && e.provide !== centerNode)
      //   if (item.length) {
      //     let provide = _.cloneDeep(item).map(e => e.provide)
      //     return provide
      //   }
      //   return _.cloneDeep(this.provideList).filter(e => e.value !== centerNode).map(e => e.name)
      // },
      otherNode () {
        // let { centerNode, nodeList } = this.nodeInfo
        let { centerNode } = this.nodeInfo
        let nodeList = this.provideList.find(e => e.value === centerNode).nodeList
        return _.cloneDeep(this.provideList).filter(e => nodeList.includes(e.value))
      }
    }
  }
</script>

<style lang="scss" scoped>
.chart {
    display: flex;
    justify-content: center;
    align-items: center;
}
.center-node {
    position: relative;
    width: 380px;
    height: 170px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(270deg, #33317e 0%, #5a58c5 100%);
    border-radius: 8px;
    box-shadow: 0px 4px 4px 0px rgba(0, 0, 0, 0.25);
    .bg {
        width: 380px;
        height: 170px;
        position: absolute;
        top: 0;
        left: 0;
        background-repeat: no-repeat;
        background-position: center;
        background-size: 100%;
        z-index: 999;
        &.cs {
            background: url(./images/img_cs_bigA.png) right center no-repeat;
        }
        &.zt {
            background: url(./images/img_zt_bigB.png) right center no-repeat;
        }
        &.xt {
            background: url(./images/img_xt_bigC.png) right center no-repeat;
        }
        &.ty {
            background: url(./images/img_ty_bigD.png) right center no-repeat;
        }
    }

    .title {
        font-size: 40px;
        font-family: YouSheBiaoTiHei, YouSheBiaoTiHei-Regular;
        font-weight: 400;
        text-align: LEFT;
        color: #ffffff;
        line-height: 40px;
        white-space: nowrap;
        // text-shadow: 0 0 2px white, 0 0 2px white, 0 0 3px white, 0 0 4px white; //设置发光效果
        text-shadow: 0px 0px 4px 0px rgba(255, 255, 255, 0.8);
    }
    .desc {
        font-size: 14px;
        font-weight: 400;
        color: #ffffff;
        line-height: 20px;
    }
}
.arrow {
    width: 200px;
    height: 170px;
    margin: 0 70px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding-top: 10px;
    .item {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 200px;
        flex: 1;
        background: url(./images/img_other_arrow.png) no-repeat center;
        font-size: 20px;
        font-weight: 600;
        text-align: center;
        color: #ffffff;
        .val {
            margin-top: -10px;
        }
    }
}
.node-list {
    width: 360px;
    height: 170px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    .node {
        position: relative;
        display: flex;
        flex-direction: column;
        justify-content: center;
        width: 360px;
        flex: 1;
        line-height: 1;
        border-radius: 8px;
        background: linear-gradient(270deg, #33317e 0%, #5a58c5 100%);
        border-radius: 8px;
        box-shadow: 0px 4px 4px 0px rgba(0, 0, 0, 0.25);
        text-align: CENTER;

        .title {
            font-size: 30px;
            font-family: YouSheBiaoTiHei, YouSheBiaoTiHei-Regular;
            font-weight: 400;
            color: #ffffff;
            white-space: nowrap;
            text-shadow: 0px 0px 4px 0px rgba(255, 255, 255, 0.8);
        }
        .desc {
            font-size: 14px;
            font-weight: 400;
            color: #ffffff;
        }
        .bg {
            width: 360px;
            height: 100%;
            position: absolute;
            top: 0;
            left: 0;
            background-repeat: no-repeat;
            background-position: center;
            background-size: 100%;
            z-index: 999;
            &.cs {
                background: url(./images/img_cs_bigA.png) right center no-repeat;
            }
            &.zt {
                background: url(./images/img_zt_bigB.png) right center no-repeat;
            }
            &.xt {
                background: url(./images/img_xt_bigC.png) right center no-repeat;
            }
            &.ty {
                background: url(./images/img_ty_bigD.png) right center no-repeat;
            }
        }
    }
    .node + .node {
        margin-top: 10px;
    }
}
</style>
